<?php
require 'config.php';
if (isset($_REQUEST['entity'])) {
	$entity = $_REQUEST['entity'];
} else {
	$entity = Constants::NULL;
	header("Location: index.php");
}
if ($entity != Constants::NULL) { //TODO : plus check entity exist 
	$pageTitle = "MR Motors | " . $_REQUEST['title'];
	include 'common/header.php';
	$conf = array('error_prepend' => '<font color="#ff0000"><tt>', 'error_append'  => '</tt></font>');
	$logger = &Log::singleton('display', '', '', $conf, PEAR_LOG_DEBUG);
	include "src/$entity/$entity.class.php";
	include "src/$entity/dao.class.php";	
	if (isset($_REQUEST['action'])) {
		$action = $_REQUEST['action'];
	} else {
		$action = $_POST['action'];
	}
	if (isset($action)) {
		switch ($action) {
			case "browse": {
				include 'common/right.php';
				include "src/$entity/browse.php";
				break;
			}
			case "search": {
				include "src/$entity/search.php";
				break;
			}
			case "finance": {
				include "src/$entity/finance.php";
				break;
			}
			case "aboutus": {
				include "src/$entity/aboutus.php";
				break;
			}
			case "contact": {
				include "src/$entity/contact.php";
				break;
			}
			case "details": {
				include "src/$entity/details.php";
				break;
			}
			case "enquiry": {
				include "src/$entity/enquiry.php";
				break;
			} 
			case "mail": {
				include "src/$entity/mail.php";
				break;
			}
		}
	}
	include 'common/footer.php';
}
?>